﻿
// Condition: Write a program that fills and prints a matrix of size (n,n) with particular structure.

using System;



class Matrix_Var1
{
    static void Main()
    {
        // 1.initial statements
        Console.Write("Enter the size of square matrix, n= ");
        int n = int.Parse(Console.ReadLine());
        int count = 1;
        int[,] matrix = new int[n,n];


        // 2. solution with two for-loops doing through all elements of matrix.

        for (int col = 0; col < n; col++)
        {
            for (int row = 0; row < n; row++)
            {
                matrix[row, col] = count;
                count++;
            }
        }

        // 3. print the matrix[n,n]

        for (int row = 0; row < n; row++)
        {
            for (int col = 0; col < n; col++)
            {
                Console.Write(matrix[row,col]+" ");
            }
            Console.WriteLine();
        }
        Console.WriteLine();
    }
}

